class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2023-05-14",
      revision: "bfc4baf25a986b5b8f70d5655fbef34916f73b74"
  version "2023-05-14"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "f214ba54cc5c6396a721b64de22afc2bb9536796fc6dfe16ef264a090d9078f2"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "87c52936036451a7caa50d915c7b7b2e001f2dbccfbf22c570dbd6eafc30058e"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "dfc51aad19c163c2b6905f381ad58caeb6b1bab577c22f09e1906449792f7502"
    sha256 cellar: :any_skip_relocation, ventura:        "ab55abf5fe20481f64f72d86e069136d095ce5116707873beaefa5721cf712a4"
    sha256 cellar: :any_skip_relocation, monterey:       "e3d85a0b2ec78d9953be433eb02f1e7e57510dbdd542f51987c897acfde962b0"
    sha256 cellar: :any_skip_relocation, big_sur:        "f567ad3371dd47b4ce744f6c80542c08ee1f366ea6223de81213cf9f625e25a7"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "77cb007cb8364c472e429493f9219f3b787167543b7eb1ba5ac781094f62c451"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
